<template>
  <view class="video-player-box">
    <!-- 会话列表剧情 -->
    <!-- <AiChat :curStoryId="curStoryId" ref="chat" v-if="curStoryDetail.storyType==='chat'" @endAiChat="endAiChat"
			:isInStory="true" :storyId="curStoryDetail.storyId" :goodsId="goodsId"></AiChat> -->
    <!-- 视频剧情  -->
    <AiVideo
      ref="video"
      v-if="curStoryDetail.storyType === 'video'"
      :autoplay="autoplay"
      :curStoryId="curStoryId"
      :storyId="curStoryDetail.storyId"
      :seekTime="curStoryDetail.seekTime"
      :storyUrl="curStoryDetail.storyUrl"
      :coverImgUrl="curStoryDetail.coverImgUrl"
      :storySet="curStoryDetail.storySet"
      :preStoryId="curStoryDetail.preStoryId"
      :nextStoryId="curStoryDetail.nextStoryId"
      :actions="curStoryDetail.actions"
      :actionsFlag="curStoryDetail.actionsFlag"
      :gameId="goodsId"
      :openQTE="curStoryDetail.openQTE"
      :QTEtype="curStoryDetail.QTEtype"
      :QTESec="curStoryDetail.QTESec"
      :selfLoop="curStoryDetail.selfLoop"
      :loopSec="curStoryDetail.loopSec"
      :isMultiVideo="curStoryDetail.isMultiVideo"
      :sectionsConfig="curStoryDetail.sectionsConfig"
      :showRecord="curStoryDetail.showRecord"
      :checkoutEvent="curStoryDetail.checkoutEvent"
      :currentInit="currentInit"
      @playTargetStory="playTargetStory"
      @selsetAction="selsetAction"
      :failText="curStoryDetail.failText"
      @gameFail="gameFail"
      @onTimeUpdate="onTimeUpdate"
      @playClickVoice="playClickVoice"
      @stopClickVoice="stopClickVoice"
      @goHome="goHome"
      @skipSectionStory="skipSectionStory"
      @playSvga="playSvga"
      @changeSvgaStyle="changeSvgaStyle"
      @openGiftPop="openGiftPop"
      @clearSvga="clearSvga"
      @onPlay="onPlay"
    >
    </AiVideo>
    <!-- 视频聊天剧情 -->
    <!-- 		<AiVideoChat ref="videoChat" v-else-if="curStoryDetail.storyType==='videoChat'" :autoplay="autoplay"
			:curStoryId="curStoryId" :storyId="curStoryDetail.storyId" :storyNextStoryId="curStoryDetail.nextStoryId"
			:actions="curStoryDetail.actions" @openGiftPop="openGiftPop" :storyUrl="curStoryDetail.storyUrl"
			:storySet="curStoryDetail.storySet" :checkoutEvent="curStoryDetail.checkoutEvent"
			:selfLoop="curStoryDetail.selfLoop" :loopSec="curStoryDetail.loopSec" :gameId="goodsId"
			@playTargetStory="playTargetStory" @videoClick="videoClick" @onTimeUpdate="onTimeUpdate"
			@playClickVoice="playClickVoice">
		</AiVideoChat> -->
    <!-- 单人文字聊天剧情 -->
    <!-- <AiSingleChat ref="singleChat" :curStoryId="curStoryId" v-else-if="curStoryDetail.storyType==='singleChat'"
			@endSingleChat="endSingleChat" :storyId="curStoryDetail.storyId" @openGiftPop="openGiftPop"
			:gameId="goodsId" @playClickVoice="playClickVoice">
		</AiSingleChat> -->
    <!-- <AiAgentChat
      ref="agentChat"
      :curStoryId="curStoryId"
      v-else-if="curStoryDetail.storyType === 'agentChat'"
      @endSingleChat="endSingleChat"
      :storyId="curStoryDetail.storyId"
      @openGiftPop="openGiftPop"
      :gameId="goodsId"
      @playClickVoice="playClickVoice"
      @playTargetStory="playTargetStory"
      @controlInput="controlInput"
      @hideInput="hideInput"
      @showInput="showInput"
    >
    </AiAgentChat> -->
    <!-- 图文聊天剧情 -->
    <!-- 		<AiImageChat ref="imageChat" @openGiftPop="openGiftPop" :curStoryId="curStoryId" :story_index="story_index"
			:current="current" v-else-if="curStoryDetail.storyType==='imageChat'" @endSingleChat="endSingleChat"
			:storyId="curStoryDetail.storyId" :gameId="goodsId" @playClickVoice="playClickVoice">
		</AiImageChat> -->
  </view>
</template>
<script>
// import AiChat from "@/components/ai-chat/index.vue"
import AiVideo from "@/components/ai-video/index.vue";
// import AiVideoChat from "@/components/ai-video-chat/index.vue"
// import AiSingleChat from "@/components/ai-single-chat/index.vue"
// import AiAgentChat from "@/components/ai-single-agent-chat/index.vue";
// import AiImageChat from "@/components/ai-image-chat/index.vue"
export default {
  components: {
    // AiChat,
    // AiSingleChat,
    AiVideo,
    // AiVideoChat,
    // AiImageChat,
    // AiAgentChat,
  },
  props: {
    curStoryId: {
      type: [String, Number],
    },
    currentInit: {
      type: Boolean,
      default: false,
    },
    autoplay: {
      type: Boolean,
      default: false,
    },
    goodsId: {
      type: [String, Number],
    },
    story_index: {
      type: [String, Number],
    },
    current: {
      type: [String, Number],
    },
    curStoryDetail: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  watch: {},
  data() {
    return {};
  },
  created() {},
  onLoad() {},

  methods: {
    onPlay(e) {
      this.$emit("onPlay", e);
    },
    clearSvga() {
      this.$emit("clearSvga");
    },
    giftAddScore(num) {
      if (this.$refs.video) {
        this.$refs.video.giftAddScore(num);
      }
    },
    showInput(callback) {
      this.$emit("showInput", callback);
    },
    hideInput(callback) {
      this.$emit("hideInput", callback);
    },
    controlInput(e) {
      this.$emit("controlInput", e);
    },
    upDateChatList(type) {
      // if (this.$refs.agentChat) {
      //   this.$refs.agentChat.upDateChatList(type);
      // }
    },
    changeInputType(type) {
      // if (this.$refs.agentChat) {
      //   this.$refs.agentChat.changeInputType(type);
      // }
    },
    pageToBottom() {
      // if (this.$refs.agentChat) {
      //   this.$refs.agentChat.pageToBottom();
      // }
    },
    setMessage(messages) {
      // if (this.$refs.agentChat) {
      //   this.$refs.agentChat.setMessage(messages);
      // }
    },
    pushUserMessage(message) {
      // if (this.$refs.agentChat) {
      //   this.$refs.agentChat.pushUserMessage(message);
      // }
    },
    pageToBottom() {
      // if (this.$refs.agentChat) {
      //   this.$refs.agentChat.pageToBottom();
      // }
    },
    changeSvgaStyle(e) {
      this.$emit("changeSvgaStyle", e);
    },
    playSvga(e) {
      this.$emit("playSvga", e);
    },
    goHome() {
      this.$emit("goHome");
    },
    skipSectionStory() {
      this.$emit("skipSectionStory");
    },
    playVideo() {
      let storyType = this.curStoryDetail.storyType;
      this.$refs[storyType].playVideo();
    },
    pauseVideo() {
      let storyType = this.curStoryDetail.storyType;
      this.$refs[storyType].pauseVideo();
    },
    stopClickVoice() {
      this.$emit("stopClickVoice");
    },
    playClickVoice(e) {
      this.$emit("playClickVoice", e);
    },
    hideTree() {
      this.$refs.video.hideTree();
    },
    hideThread() {
      this.$refs.video.hideThread();
    },
    // showBuyPage() {
    // 	console.log('被调用');
    // 	this.$refs.video.showBuyPage()
    // },
    onTimeUpdate(e) {
      this.$emit("onTimeUpdate", e);
    },
    videoClick() {
      this.$emit("videoClick");
    },

    gameFail(data) {
      this.$emit("gameFail", data);
    },
    reloadChat(type) {
      if (type == "singleChat") {
        this.$refs.singleChat.reset();
      } else {
        return;
      }
    },
    stopStory(callback, destory = false) {
      let storyType = this.curStoryDetail.storyType;
      this.$refs[storyType].stopStory((load) => {
        callback(load);
      }, destory);
    },
    getDuration(callback) {
      let storyType = this.curStoryDetail.storyType;
      this.$refs[storyType].getDuration((load) => {
        callback(load);
      });
    },
    setNextStoryId(nextStoryId) {
      // this.$refs.videoChat.setNextStoryId(nextStoryId)
    },

    playTargetStory([nextStoryId, callback], seekTime = 0) {
      this.$emit("playTargetStory", [nextStoryId, callback], seekTime);
    },

    openGiftPop() {
      this.$emit("openGiftPop");
    },
    // 跳转视频进度
    seekEvent(seekEventTime) {
      let storyType = this.curStoryDetail.storyType;
      this.$refs[storyType].seekEvent(seekEventTime);
    },
    selsetAction(action, callback) {
      this.$emit("selsetAction", action, (flag) => {
        callback(flag);
      });
    },
    canChangeCurrent(callback) {
      let storyType = this.curStoryDetail.storyType;
      this.$refs[storyType].canChangeCurrent((load) => {
        callback(load);
      });
    },

    onEndedEvent(callback) {
      let storyType = this.curStoryDetail.storyType;
      this.$refs[storyType].onEndedEvent((load) => {
        callback(load);
      });
    },

    startPlay(callback, seekTime = 0) {
      switch (this.curStoryDetail.storyType) {
        case "video":
          this.$refs.video.startPlay((flag) => {
            callback(flag);
          }, seekTime);
          break;
        case "chat":
        // this.$refs.chat.startPlay((flag) => {
        // 	callback(flag)
        // })
        // break;
        case "videoChat":
          // this.$refs.videoChat.startPlay((flag) => {
          // 	callback(flag)
          // })
          break;
        case "singleChat":
          this.$refs.singleChat.startPlay((flag) => {
            callback(flag);
          });
          break;

        case "agentChat":
          // this.$refs.agentChat.startPlay((flag) => {
          //   callback(flag);
          // });
          break;
        case "imageChat":
          // this.$refs.imageChat.startPlay((flag) => {
          // 	callback(flag)
          // })
          break;
      }
    },

    endAiChat(storyId) {
      this.$emit("endAiChat", storyId);
    },
    endSingleChat(nextStoryId) {
      this.$emit("endSingleChat", nextStoryId);
    },
  },
};
</script>
<style lang="scss">
@import "./index.scss";
</style>